/**
 * Created with JetBrains WebStorm.
 * User: liuyong
 * Date: 14-4-12
 * Time: 上午12:20
 * To change this template use File | Settings | File Templates.
 */

var aiuiApp = angular.module('ai.progress', ['template/progress/progress.html']);
angular.module("s", []).run(["$templateCache", function($templateCache) {
    $templateCache.put("template/progress/progress.html",
	        "<div  class=\"progress-status\" ng-style=\"showStyle\">" +
	            "     <ol class=\"progress-steps \">     " +
	            "      <li ng-class=\"     " +
	            " {'step-first':$index==0,'step-done':progressData.currentStep>$index,'step-now':progressData.currentStep==$index, 'step-last':$index==progressData.stepTexts.length-1}\"      " +
	            " class=\"step\" ng-repeat=\"step in progressData.stepTexts\">       " +
	            "      <div class=\"step-line\">   " +
	            "      <div class=\"step-dot\">   " +
	            "       </div>      " +
	            "      </div>   " +
	            "    <div class=\"step-text\">{{step}}</div>  " +
	            " </li>     " +
	            " </ol>" +
	            "</div>   " +
            "");
}]);
aiuiApp.controller('ProgressController', ['$scope', '$attrs', function ($scope, $attrs) {
    // $scope.closeable = 'close' in $attrs;
}]);
aiuiApp.directive('aiProgress', function () {
    return {
        restrict:'EA',
        controller:'ProgressController',
        templateUrl:'template/progress/progress.html',
        transclude:true,
        replace:true,
        scope: {
            progressData: '='
        },
        controller: function ($scope) {
        	$scope.show=function(event)
        	{
        		$scope.statusShow=true;
        		var rt = ($(window).width() - (event.target.offsetLeft ))+'px';
        		$scope.showStyle = {'z-index': 102,position: 'absolute', right: rt,top: event.target.offsetTop+'px'};
        	}
        }
    };
});

//百度编辑器
var editorApp = angular.module('ai.editor', []);
editorApp.directive('editor', [function() {
    return {
        restrict: 'A'
        , scope: {
            content: '='
        }
        , link: function(scope, element, attrs){

          var editor = new UE.ui.Editor({initialContent: scope.content});
          editor.render(element[0]);

          editor.ready(function(){
            editor.addListener('contentChange', function(){
              scope.content = editor.getContent();
              scope.$root.$$phase || scope.$apply();
            });

            /*scope.$watch('content', function(newValue){
              editor.setContent(newValue);
            });*/
          });
        }
    };
}]);